@@ -38,3 +38,11 @@ rm -rf /usr/share/doc/ |
||
38 | 38 |
rm -rf /usr/share/man/ |
39 | 39 |
rm -rf /usr/share/locale/ |
40 | 40 |
rm -rf /var/log/* |
41 |
+ |
|
42 |
+# add a huginn group and user |
|
43 |
+adduser --group huginn |
|
44 |
+adduser --disabled-login --ingroup huginn --gecos 'Huginn' --no-create-home --home /app huginn |
|
45 |
+passwd -d huginn |
|
46 |
+ |
|
47 |
+mkdir -p /app/lib/ |
|
48 |
+mkdir -p /app/vendor/gems |
@@ -0,0 +1,28 @@ |
||
1 |
+#!/bin/bash |
|
2 |
+set -e |
|
3 |
+ |
|
4 |
+cd /app |
|
5 |
+ |
|
6 |
+export LC_ALL=en_US.UTF-8 |
|
7 |
+ |
|
8 |
+# Ensure the huginn user has access to the required directories |
|
9 |
+sudo -u huginn -H mkdir -p tmp/pids tmp/cache tmp/sockets log |
|
10 |
+sudo -u huginn -H touch log/production.log |
|
11 |
+# Get rid of annoying "fatal: Not a git repository (or any of the parent directories): .git" messages |
|
12 |
+sudo -u huginn -H git init |
|
13 |
+ |
|
14 |
+# HACK: We need a database connection to precompile the assets, use sqlite for that |
|
15 |
+cp Gemfile Gemfile.bak |
|
16 |
+echo "gem 'sqlite3', '~> 1.3.11'" >> /app/Gemfile |
|
17 |
+RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4 |
|
18 |
+RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle exec rake assets:clean assets:precompile |
|
19 |
+ |
|
20 |
+# Bundle again to get rid of the sqlite3 gem |
|
21 |
+cp Gemfile.bak Gemfile |
|
22 |
+RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4 |
|
23 |
+ |
|
24 |
+# Configure the unicorn server |
|
25 |
+mv config/unicorn.rb.example config/unicorn.rb |
|
26 |
+sed -ri 's/^listen .*$/listen ENV["PORT"]/' config/unicorn.rb |
|
27 |
+sed -ri 's/^stderr_path.*$//' config/unicorn.rb |
|
28 |
+sed -ri 's/^stdout_path.*$//' config/unicorn.rb |
@@ -1,15 +1,23 @@ |
||
1 | 1 |
FROM ubuntu:14.04 |
2 | 2 |
MAINTAINER Dominik Sander |
3 | 3 |
|
4 |
-ADD scripts/prepare /scripts/prepare |
|
4 |
+ADD docker/scripts/prepare /scripts/prepare |
|
5 | 5 |
RUN /scripts/prepare |
6 | 6 |
|
7 |
-ADD scripts/setup /scripts/setup |
|
8 |
-RUN /scripts/setup |
|
9 |
- |
|
10 | 7 |
WORKDIR /app |
11 | 8 |
|
12 |
-ADD scripts/init /scripts/init |
|
9 |
+ADD ["Gemfile", "Gemfile.lock", "/app/"] |
|
10 |
+ADD lib/gemfile_helper.rb /app/lib/ |
|
11 |
+ADD vendor/gems /app/vendor/gems |
|
12 |
+ |
|
13 |
+RUN chown -R huginn:huginn /app && \ |
|
14 |
+ sudo -u huginn -H echo "gem 'sqlite3', '~> 1.3.11'" >> /app/Gemfile && \ |
|
15 |
+ sudo -u huginn -H LC_ALL=en_US.UTF-8 RAILS_ENV=production ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4 |
|
16 |
+COPY . /app |
|
17 |
+ |
|
18 |
+ADD ["docker/scripts/setup", "docker/single-process/scripts/init", "/scripts/"] |
|
19 |
+ |
|
20 |
+RUN /scripts/setup |
|
13 | 21 |
|
14 | 22 |
EXPOSE 3000 |
15 | 23 |
|
@@ -1,36 +0,0 @@ |
||
1 |
-#!/bin/bash |
|
2 |
-set -e |
|
3 |
- |
|
4 |
-# add a huginn group and user |
|
5 |
-adduser --group huginn |
|
6 |
-adduser --disabled-login --ingroup huginn --gecos 'Huginn' --no-create-home --home /app huginn |
|
7 |
-passwd -d huginn |
|
8 |
- |
|
9 |
-# Shallow clone the huginn project repo |
|
10 |
-git clone --depth 1 https://github.com/cantino/huginn /app |
|
11 |
- |
|
12 |
-# Change the ownership to huginn |
|
13 |
-chown -R huginn:huginn /app |
|
14 |
- |
|
15 |
-cd app |
|
16 |
- |
|
17 |
-# create required tmp and log directories |
|
18 |
-sudo -u huginn -H mkdir -p tmp/pids tmp/cache tmp/sockets log |
|
19 |
-chmod -R u+rwX log tmp |
|
20 |
- |
|
21 |
-export LC_ALL=en_US.UTF-8 |
|
22 |
- |
|
23 |
-# HACK: We need a database connection to precompile the assets, use sqlite for that |
|
24 |
-echo "gem 'sqlite3', '~> 1.3.11'" >> Gemfile |
|
25 |
-sudo -u huginn -H RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4 |
|
26 |
-sudo -u huginn -H RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle exec rake assets:clean assets:precompile |
|
27 |
-git checkout Gemfile |
|
28 |
- |
|
29 |
-# Bundle again to get rid of the sqlite3 gem |
|
30 |
-sudo -u huginn -H ON_HEROKU=true DATABASE_ADAPTER=noop bundle install --without test development --path vendor/bundle |
|
31 |
- |
|
32 |
-# Configure the unicorn server |
|
33 |
-mv config/unicorn.rb.example config/unicorn.rb |
|
34 |
-sed -ri 's/^listen .*$/listen ENV["PORT"]/' config/unicorn.rb |
|
35 |
-sed -ri 's/^stderr_path.*$//' config/unicorn.rb |
|
36 |
-sed -ri 's/^stdout_path.*$//' config/unicorn.rb |